//
//  UserUntils.m
//  DailyRecord
//
//  Created by Gin on 2022/3/25.
//

#import "UserUntils.h"
#import "UserStorage.h"

@implementation UserUntils

SYNTHESIZE_SINGLETON_FOR_CLASS(UserUntils);

- (instancetype)init{
    if (self = [super init]) {
        User *user = [UserStorage loadUser];
        self.user = user;
    }
    return self;
}

- (Boolean)userIsLogined{
    return self.user != nil;
}

- (void)updateUser:(User *)user{
    self.user = user;
    [UserStorage storeUser:[user yy_modelToJSONData]];
}

- (void)logoutAndFlush{
    [UserStorage storeUser:nil];
    self.user = nil;
    [self clearMemoryCache];
}

- (void)clearMemoryCache{

}

@end
